package com.myapp.struts.action;

import com.myapp.hibernate.model.Estadio;
import com.myapp.hibernate.util.EstadioUtil;
import com.myapp.struts.form.EstadiosForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author jiglrom
 */
public class ModificarEstadioAction extends org.apache.struts.action.Action {

    private static final String SUCCESS = "success";

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        EstadiosForm formulario = (EstadiosForm)form;
        EstadioUtil estadioUtil = new EstadioUtil();
        Estadio e = estadioUtil.obtenerEstadio(formulario.getIdEstadio());
        formulario.setNombre(e.getNombre());
        formulario.setAforo(e.getAforo());
        formulario.setIdEstadio(e.getIdEstadio());
        return mapping.findForward(SUCCESS);
    }
}
